package com.budweiser.user.dao;

import com.budweiser.model.organ.Organization;
import com.budweiser.user.dto.OrganSelectTree;
import com.budweiser.user.dto.OrganizationTree;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrganizationDao {
	/***
	 * 根据机构对象构建表格树形
	 * 
	 * @return
	 */
	List<OrganizationTree> getOrgainByAll();

	/***
	 * 根据机构对象构建下拉树形
	 * 
	 * @return
	 */
	List<OrganSelectTree> getOrganSelectTree();

	/***
	 * 新增机构
	 * 
	 * @param organization
	 */
	void insert(Organization organization);

	/***
	 * 批量修改删除状态
	 * 
	 * @param ids
	 */
	void deleteIds(List<Long> ids);

	/***
	 * 修改机构
	 * 
	 * @param
	 */
	void update(Organization organization);

	/***
	 * 最大Id
	 * 
	 * @return
	 */

	String getMaxId();

	/***
	 * 根据父类id查询父类结构
	 * 
	 * @param parentid
	 * @return
	 */
	@Select("select * from sys_organ where id = #{parentid}")
    Organization getOrganizationByPid(Long parentid);
    /***
     *  根据id查询子类
     * @param id
     * @return
     */
	@Select("select * from sys_organ where parentid = #{id}")
	List<Organization> getOrganizationChild(Long id);
	/***
	 * 根据id的查询
	 * @param id
	 * @return
	 */
	@Select("select * from sys_organ where id = #{id}")
    Organization getOrganizationByid(Long id);
    /****
     * 根据名称查询
     * @param orgname
     * @return
     */
	@Select("select * from sys_organ where name = #{orgname}")
    Organization getOrganizationByName(String orgname);

}
